<script>
	export default {
		onLaunch: function() {
			console.log('App Launch')
			uni.login({
				provider: 'weixin',
				success: res => {
					uniCloud.callFunction({
						name: 'user',
						data: {
							action: 'appid',
							js_code: res.code
						},
						success: Res => {
							uni.setStorageSync('openid', Res.result.openid)
							uniCloud.callFunction({
								name: 'user',
								data: {
									action: 'getUser',
									open_id: Res.result.openid
								},
								success: res => {
									if (res.result != null && res.result != '') {
										uni.setStorageSync('userInfo', res.result)
										uni.setStorageSync('isLogin', true)
									} else {
										uni.setStorageSync('isLogin', false)
									}
								},
								fail: err => {
									console.log('err', err)
								}
							})
						}
					})
				}
			})

		},
		onShow: function() {
			console.log('App Show')
		},
		onHide: function() {
			console.log('App Hide')
		}
	}
</script>


<style lang="scss">
	@import "colorui/main.css";
	@import "colorui/icon.css";

	/*每个页面公共css */
	page {
		/* background-color: #F7F8FA; */
		background-color: #FFF;
	}
</style>